package de.chrisbremer.hydromap;

/**
 * @author 	chris
 * @date   	2011-12-23
 */

import android.app.Activity;
import android.content.Context;
import android.database.Cursor;
import android.os.Bundle;
import android.widget.SimpleCursorAdapter;
import android.widget.Spinner;
import de.chrisbremer.hydromap.R;

public class Utilities extends Activity {
	static DatabaseHelper mDbHelper;
	static Cursor mCur;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}
	@Override
	protected void onDestroy() {
		mCur.close();
		mDbHelper.close();
		super.onDestroy();
	}
	static public void ManageTypeSpinner(Context context,Spinner view)
	{
		mDbHelper=new DatabaseHelper(context);
		mCur=mDbHelper.getAllTyps();
		SimpleCursorAdapter ca=new SimpleCursorAdapter(context,R.layout.typespinnerrow, mCur, new String [] {DatabaseHelper.colTypeDescription,"_id"}, new int []{R.id.txtTypeName});
		view.setAdapter(ca);
		mDbHelper.close();
	}
	static public void ManagePositionSpinner(Context context,Spinner view)
	{
		mDbHelper=new DatabaseHelper(context);
		mCur=mDbHelper.getAllPositions();
		SimpleCursorAdapter ca=new SimpleCursorAdapter(context,R.layout.positionspinnerrow, mCur, new String [] {DatabaseHelper.colPositionDescription,"_id"}, new int []{R.id.txtPositionName});
		view.setAdapter(ca);
		mDbHelper.close();
	}

}
